<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
	<include file="Public:meta" />
	<style>
		.type1{ color: #000; /*其它操作*/}
		.type2{ color: blue; /*添加*/}
		.type3{ color: red; /*删除*/}
		.type4{ color: #F60; /*修改*/}
		.type5{ color: #30F; /*排序*/}
		.type6{ color: green; /*导出*/}
		.type7{ color:#666; /*清除缓存*/}
		.type8{ color:#F0F; /*登录/退出*/}
		.type9{ color:#600; /*发送短信*/}
	</style>
</head>
<body id="main_page">
<include file="Public:position" />
<div class="container">
    <form enctype="multipart/form-data" method="post" id="frm">
        <input type="hidden" name="p" id="p" value="{$NowPage}" />
        <div class="table">
           <div class="toolbars">
                <li class="toolbar"><a id="btnSaveAll" onclick="delAll()"  title="清除所有日志" target="_self">清除所有日志</a></li>
                <li class="toolbar"><a id="btnSave" onclick="getLocation()"  title="根据IP获取地理位置" target="_self">获取IP地理位置</a></li>
                <li class="toolbar"><a id="btnConfig" href="{$Url}/config"  title="设置">&nbsp;设置</a></li>
                <li class="toolbar"><a id="selectall" onclick="CheckAll()"  title="全选">全选</a></li>
                <li class="toolbar"><a id="del" onclick="batchDel()" title="批量删除">删除</a></li>
                <li class="toolbar"><a id="sortall" href="{$Url}index" title="刷新">刷新</a></li>
                <li class="toolbar toolbarform">
                    <label>用户名</label>
                    <input type="text" class='textinput' name="UserName" style="width:130px" value="{$UserName}" id="UserName"/>
                    <label>操作类型</label>
                    <select id="LogType" name="LogType">
                        <option value="">所有</option>
                        <option value="2">添加</option>
                        <option value="3">删除</option>
                        <option value="4">修改</option>
                        <option value="5">排序</option>
                        <option value="6">导出</option>
                        <option value="7">清除缓存</option>
                        <option value="8">登录/退出</option>
                        <option value="9">发送短信</option>
                        <option value="1">其它操作</option>
                    </select>
                    <input id="btnSeek" class="btnToolbarForm" type="submit" value="查询" onclick="Search()">
                </li>
            </div>
            <table class="datatable" id="datatable">
                <tr>
                     <th width="40px"  nowrap="nowrap">选中</th>
                     <th width="55px" >日志ID</th>
                     <th width="150px" >用户名</th>
                     <th width="120px" >操作时间</th> 
                     <th width="230px" >IP地址</th>
                     <th width="60px" >语言</th>
                     <th width="200px" >操作项目</th>
                     <th>备注</th>
                </tr>  
                <notempty name="Data">
                <volist name="Data" id="d">
                    <tr>
                        <td><input class="checkrow" type="checkbox" name="id[]" value="{$d.LogID}" /></td>
                        <td>{$d.LogID}</td>
                        <td>{$d.UserName}</td>
                        <td>{$d.LogTime|strtotime|yd_friend_date}</td>
                        <td>{$d.UserIP}&nbsp;&nbsp;<b style="color:#F30">{$d.UserCity}</b>
                        <input type="hidden" name="UserIP[]" value="{$d.UserIP}" />
                        </td>
                        <td>
                            <eq name="d.LanguageID" value="1">
                                <b style="color:#0000FF">中文版</b>
                            <else/>
                                <b style="color:#F30">英文版</b>
                            </eq>
                        </td>
                        <td><span class="type{$d.LogType}">{$d.UserAction}</span></td>
                        <td style="text-align:left;">{$d.LogDescription}</td>
                    </tr>
                </volist>
                <else/>
                    <tr><td colspan="8" id="NoData">{$Think.lang.NoDataTip}</td></tr>
                </notempty>                                  
            </table>
             <div class="tfoot">
                  <div class="page"><span class="pagesize">每页<span class="pz">{$AdminPageSize}</span>条</span>{$Page}</div>
             </div>
        </div>
    </form>
</div>
</body>
</html>
<script type="text/javascript">
$(document).ready(function(){
	pageInit();
});

function pageInit(){
	$("#LogType").val( "{$LogType}");
}

function del(id){
	$.confirm("{$Think.lang.DeleteTip}", function () {
		url = "{$Url}del/id/"+id;
		location.href = url;
	}, function () {
		return true;
	});
}

function delAll(){
	$.confirm("确定清空所有数据吗？", function () {
		location.href = "__URL__/delAll";
	}, function () {
		return true;
	});
}

function getLocation(){
	var arrChk = $("input[name='id[]']");
	var n = 0;
	for(var i = 0; i < arrChk.length; i++){
		if(arrChk[i].checked) n++;
	}
	
	if( n == 0 ) {
		WarnBox("请选中至少一条记录!");
		return;
	}
	LoadBox("获取地理位置中，请稍后...");
	var url = "{$Url}index?p={$NowPage}&UserName={$UserName}&LogType={$LogType}";
	$('#frm').attr("action", "__URL__/getLocation");
	$('#frm').ajaxSubmit( {success: function(data){
		window.location.href = url;
	},dataType: 'json'} );
}

function batchDel(){
	//var arrChk = $("input[name='InfoID[]'][checked]"); //在高速浏览器长度总是返回0
	var arrChk = $("input[name='id[]']");
	var n = 0;
	for(var i = 0; i < arrChk.length; i++){
		if(arrChk[i].checked) n++;
	}
	
	if( n == 0 ) {
		WarnBox("{$Think.lang.CheckDeleteTip}");
		return;
	}
	
	$.confirm("{$Think.lang.DeleteTip}", function () {
		$('#frm').attr("action", "__URL__/del");
		$('#frm').submit();
	}, function () {
		return true;
	});
}

//查询
function Search(){
	$('#frm').attr("action", "{$Url}index");
	$('#frm').submit();
	return true;
}	
</script>